package com.slipper.common.excel;


import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.slipper.common.excel.parse.ICellParse;
import com.slipper.common.excel.parse.support.*;

public class CellParseFactory {
    private final Map<Class<?>, ICellParse> cellParseMap = new HashMap<>();

    private CellParseFactory() {
        this.cellParseMap.put(Integer.class, new IntegerParse());
        this.cellParseMap.put(int.class, new IntegerParse());
        this.cellParseMap.put(Long.class, new LongParse());
        this.cellParseMap.put(long.class, new IntegerParse());
        this.cellParseMap.put(Double.class, new DoubleParse());
        this.cellParseMap.put(double.class, new DoubleParse());
        this.cellParseMap.put(Date.class, new DateParse());
        this.cellParseMap.put(String.class, new StringParse());
        this.cellParseMap.put(BigDecimal.class, new BigDecimalParse());
    }

    private static final class Holder {
        static final CellParseFactory instance = new CellParseFactory();
    }

    public static CellParseFactory getInstance() {
        return Holder.instance;
    }

    public ICellParse getCellParse(Class<?> clazz) {
        return this.cellParseMap.get(clazz);
    }
}
